<template>
  <div class="auto" style="margin-top: 5px">
    <criteria-paged :model="model" v-ref:paged >
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div novalidate class="form-inline" partial>
         <!-- <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_typename" placeholder='检查内容'
                    condition="u.f_itemname = '{}'"
                    :size="model.f_typename ? model.f_typename.length : 4">
          </div>
          <div class="form-group">
            <button class="btn btn-success width-80" @click="search()">查询</button>
          </div>-->
        </div>
      </criteria>
      <data-grid :model='model' partial='list' v-ref:grid>
        <template partial='head'>
            <th>序号</th>
            <th>检查内容</th>
            <th>操作</th>
        </template>
        <template partial='body'>
          <td class="btd">{{$index+1}}</td>
          <td class="btd">{{row.f_typename}}</td>
          <td class="btd">
            <button class="btn btn-link" @click.stop="$parent.$parent.$parent.del(row.id)"> 删除 </button>
          </td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
  import { PagedList, setClass } from 'vue-client'
  import Vue from 'vue'

  export default {
    title: 'modelright',
    props: {
      // 安检项id号
      itemId: {}
    },
    data () {
      return {
        model: new PagedList('rs/sql/getType', 10, {f_type_id : 2 })
      }
    },
    watch: {
      itemId (val) {
        this.model.paramSource = {f_type_id: val}
        this.model.search("")
      }
    },
    methods: {
      del (id){
        this.$showMessage('删除后不可恢复，确认删除？', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            this.$resetpost('rs/logic/delinfo', {data: {typeid: id}}).then((res) => {
              this.refresh ()
            })
          }
        })
      },
      refresh (){
        this.model.refresh()
      }
    }
  }
</script>

<style scoped>
  .btd{
    text-align:center;
  }
</style>
